PreviousTracker indexSee it online !

(212/212) 540 - System Information Macro - useful for reporting bugs

I think, this macro could be a good additon to default jEdit.

The "SystemInformation Macro will display:
jEdit Version
Java Version
OS Name & Version
Every Plugin Name & Version

Information can be copied to the clipboard.

StringBuilder result= new StringBuilder(1024);
result.append("jEdit: ");
result.append(jEdit.getBuild());
result.append("\n");
result.append("Java: ");
result.append(System.getProperty("java.vendor"));
result.append(" ");
result.append(System.getProperty("java.version"));
result.append("\n");
result.append("OS: ");
result.append(System.getProperty("os.name"));
result.append(" ");
result.append(System.getProperty("os.version"));
result.append(" ("+System.getProperty("os.arch"));
result.append(")\n");

EditPlugin[] pis= jEdit.getPlugins();
for (i=0; i<pis.length; ++i) {
String clazz= pis[i].getClassName();
result.append("\n");
result.append(jEdit.getProperty("plugin."+clazz+".name"));
result.append(": ");
result.append(jEdit.getProperty("plugin."+clazz+".version"));
}
int answer= Macros.confirm(view, "jEdit Version Information\n\n" + result.toString()+"\n\nCopy to clipboard?", JOptionPane.YES_NO_OPTION);
if (answer == JOptionPane.YES_OPTION) {
Registers.setRegister('$', result.toString());
}


Submitted ngc - 2017-11-01 12:10:11.407000 Assigned
Priority 5 Labels Macro
Status open Group none
Resolution None

Comments

2017-11-03 00:46:31.215000
tsourick

Nice.

But could you please put the info inside a scrollable selectale area (textArea?), make shorter and wider popup and visually separate buttons, one close/ok button at the center and another one to copy, on its own line above or aligned to the right or both.

I also believe that this should be put under Utilities -> Troubleshooting menu.

2017-11-03 07:58:46.795000
ngc

Personally I cannot (yet) as my experience with Java isn't the best.

Maybe you can enhance the macro?

I'm just using standard Macros-provided methods to display the text. Everything beyond that is above my current capabilities :(

2017-11-03 13:32:01.298000
ngc

Okay... Using jEdit's help as a guideline I came up with this:

// import statement
import javax.swing.border.*;

StringBuilder result= new StringBuilder(1024);
result.append("jEdit: ");
result.append(jEdit.getBuild());
result.append("\n");
result.append("Java: ");
result.append(System.getProperty("java.vendor"));
result.append(" ");
result.append(System.getProperty("java.version"));
result.append("\n");
result.append("OS: ");
result.append(System.getProperty("os.name"));
result.append(" ");
result.append(System.getProperty("os.version"));
result.append(" ("+System.getProperty("os.arch"));
result.append(")\n");

EditPlugin[] pis= jEdit.getPlugins();
for (i=0; i<pis.length; ++i) {
String clazz= pis[i].getClassName();
result.append("\n");
result.append(jEdit.getProperty("plugin."+clazz+".name"));
result.append(": ");
result.append(jEdit.getProperty("plugin."+clazz+".version"));
}

// create dialog object
String title = "About jEdit";
JDialog dialog = new JDialog(view, title, false);
JPanel content = new JPanel(new BorderLayout());
content.setBorder(new EmptyBorder(12, 12, 12, 12));
dialog.setContentPane(content);

// Format the result
JLabel html= new JLabel(
"<html><head><style type=\"text/css\">th { text-align: left; }</style><body><table>"
+ result.toString().replaceAll("(?m)^(.*?): (.*)$","<tr><th>$1</th><td>$2</td></tr>")
+ "</table></body></html>"
);
JScrollPane scroller = new JScrollPane(html, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
content.add(scroller, "Center");

// add the buttons
buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel,
BoxLayout.X_AXIS));
buttonPanel.setBorder(new EmptyBorder(12, 50, 0, 50));
buttonPanel.add(Box.createGlue());
JButton ok = new JButton("OK");
JButton copy = new JButton("Copy");
ok.setPreferredSize(copy.getPreferredSize());
dialog.getRootPane().setDefaultButton(ok);
buttonPanel.add(ok);
buttonPanel.add(Box.createHorizontalStrut(6));
buttonPanel.add(copy);
buttonPanel.add(Box.createGlue());
content.add(buttonPanel, "South");

// register this method as an ActionListener for
// the buttons and text fields
ok.addActionListener(this);
copy.addActionListener(this);

// locate the dialog in the center of the
// editing pane and make it visible
dialog.pack();
dialog.setLocationRelativeTo(view);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);

// this method will be called when a button is clicked
// or when ENTER is pressed
void actionPerformed(e)
{
if(e.getSource() == copy)
{
Registers.setRegister('$', result.toString());
}
dialog.dispose();
}

Hope you like it.